﻿using System.Xml.Linq;
using TVersityDotNet.HelperTypes;
using TVersityDotNet.Responses;
using System.Globalization;

namespace TVersityDotNet.Requests
{
    public class MediaSourcePoliteFetchListRequest : TVersityRequest
    {
        private MediaSourceType _mediaSourceType;

        public MediaSourcePoliteFetchListRequest(MediaSourceType mediaSourceType)
        {
            base.Path = "mediasource/politefetchlist";
            this._mediaSourceType = mediaSourceType;
        }

        /// <summary>
        /// Returns the whole string, minus the baseurl used to process this query
        /// </summary>
        public override string RequestString
        {
            get
            {                
                return string.Format(CultureInfo.InvariantCulture, "{0}?type={1}", this.Path, MediaSource.GetMediaTypeName(this._mediaSourceType).ToLowerInvariant());
            }
        }

        public override TVersityResponse CreateResponse(XDocument xmlDocument)
        {
            MediaSourceFetchListResponse response = new MediaSourceFetchListResponse(xmlDocument);
            return response;
        }
    }
}
